package com.ete.service.service.version.processor

import com.blankj.utilcode.util.ActivityUtils
import com.ete.service.dialog.CommonDialog
import com.ete.service.dialog.version.CheckVersionDialog
import com.ete.service.dialog.version.UpgradeVersionDialog
import com.ete.service.entry.dialog.CommonDialogEntry
import com.ete.service.entry.version.VersionEntry
import com.ete.service.entry.version.VersionUpgradeInfo

/**
 * Author:LiXian
 * <p>
 * Desc:TODO
 * Version:1.0
 * date 2023/12/20 13:15
 */
class VersionProcessor(var mVersionEntry: VersionEntry) {

    /**
     * 显示升级提示框
     */
    fun showUpgradeDialog(mUpgradeInfo: VersionUpgradeInfo, mCancelCallback: (() -> Unit)? = null) {
        val mContext = ActivityUtils.getTopActivity() ?: return
        val mUpgradeDialog = UpgradeVersionDialog(mContext, mVersionEntry, mUpgradeInfo, mCancelCallback)
        mUpgradeDialog.initDialog()
        mUpgradeDialog.show()
    }

    /**
     * 显示检测版本提示框
     */
    fun showCheckVersionDialog(): CheckVersionDialog? {
        val mContext = ActivityUtils.getTopActivity() ?: return null
        val mCheckDialog = CheckVersionDialog(mContext, mVersionEntry.mAppThemeColor)
        mCheckDialog.initDialog()
        return mCheckDialog
    }

    /**
     * 通用提示框
     */
    fun showCommonDialog(mEntry: CommonDialogEntry): CommonDialog {
        val mCommonDialog = CommonDialog(mEntry)
        mCommonDialog.initDialog()
        return mCommonDialog
    }
}